﻿function sendCommentDeal() {
    if (objLogin != null) {
        if ($("txtCommentDeal").value.length > 0) {
            $("btnSend").onclick = "";
            var strUrlLocation = window.location.href;
            var strUrlLink = strPathLink_All;
            if (strUrlLocation.toLowerCase().indexOf("/yahoo/") != -1) {
                strUrlLink = strPathLink_All + "yahoo/";
            }
            utils.call(strUrlLink+"Deal_Comment.aspx", { "flag": "insert", "desc": $("txtCommentDeal").value, "id": strDealID }, "POST", "sendCommentDealResult", "sendCommentDealResult");
        }
    } else {
        showPopUpSIBuy();
    }
}
function sendCommentDealResult(strResult) {
    if (strResult != "0") {
        $("txtCommentDeal").value = "";
        $("btnSend").onclick = sendCommentDeal;
        var strUrlLocation = window.location.href;
        var strUrlLink = strPathLink_All;
        if (strUrlLocation.toLowerCase().indexOf("/yahoo/") != -1) {
            strUrlLink = strPathLink_All + "yahoo/";
        }
        utils.call(strUrlLink + "Deal_Comment.aspx", { "flag": "view", "id": strDealID }, "POST", "showCommentsByDeal", "showCommentsByDeal");
    }
}
function showCommentsByDeal(objComment) {
    var strUrlLocation = window.location.href;
    var strUrlLink = strPathLink_All;
    if (strUrlLocation.toLowerCase().indexOf("/yahoo/") != -1) {
        strUrlLink = strPathLink_All + "yahoo/";
    }
    var strHtml = "";
    for (var i = 0; i < objComment.dsComment.length; i++) {
        strHtml += "<li>" +
                        "<div class='dListCMSP'>" +
                               "<div class='div_imgList'>" +
                                "<a class='aImgMember aMemberListDis' href='" + strUrlLink + "profile/photos.aspx?mid=" + objComment.dsComment[i].idtk + "'><img width='50' height='50' src='" + objComment.dsComment[i].avatar + "'></img></a>" +
                                "<i class='divShadowListCW'></i>" +
                               "</div>" +
                               "<div class='TextComCP'>" +
                                    "<i class='tl_BPro'></i>" +
                                    "<i class='ct_BPro'></i>" +
                                    "<i class='tr_BPro'></i>" +
                                    "<div class='cl_BPro'>" +
                                        "<div class='cr_BPro'>" +
                                            "<div class='div_innerCP'>" +
                                                "<p class='pTimeCP'>" + objComment.dsComment[i].tgtao + "</p>" +
                                                "<a class='aMemberCP' title='" + objComment.dsComment[i].nickname + "' href='" + strUrlLink + "profile/photos.aspx?mid=" + objComment.dsComment[i].idtk + "'>" + objComment.dsComment[i].nickname + "</a>" +
                                                "<p class='pTextCP'>" + objComment.dsComment[i].noidung + "</p>" +
                                            "</div>" +
                                        "</div>" +
                                    "</div>" +
                                    "<i class='bl_BPro'></i>" +
                                    "<i class='cb_BPro'></i>" +
                                    "<i class='br_BPro'></i>" +
                                    "<div class='dAddCMBinhSP' onclick='showSubCommentSP(" + objComment.dsComment[i].idcomment + ")'>" +
                                        "<i class='iLCMBinhSP'></i>" +
                                        "<div class='dBCMBinhSP'><strong id='subCount_" + objComment.dsComment[i].idcomment + "'>" + objComment.dsComment[i].counts + "</strong><span>comments</span></div>" +
                                        "<i class='iRCMBinhSP'></i>" +
                                    "</div>" +
                                    "<i class='div_ArrowCP'></i>" +
                               "</div>" +
                           "</div>" +
                           "<div class='dAddListCMSP' id='divSubComment_" + objComment.dsComment[i].idcomment + "' style='display:none'></div>" +
                          "</li>";
    }
    $("ulComment").innerHTML = strHtml;
    if ($("btnSend")) $("btnSend").onclick = sendCommentDeal;
}

//show comment by id comment
var strIDCommentSP = '';
function showSubCommentSP(iIDComment) {
    if ($("divSubComment_" + iIDComment).style.display == "block") {
        $("divSubComment_" + iIDComment).style.display = "none";
    } else {
        strIDCommentSP = iIDComment;
        var strUrlLocation = window.location.href;
        var strUrlLink = strPathLink_All;
        if (strUrlLocation.toLowerCase().indexOf("/yahoo/") != -1) {
            strUrlLink = strPathLink_All + "yahoo/";
        }
            utils.call(strUrlLink + "Deal_Comment.aspx", { "flag": "showsub", "id": iIDComment }, "POST", "showSubCommentSPResult", "showSubCommentSPResult");
    }
}
function showSubCommentSPResult(obj) {
    var strHtml = "";
    var strUrlLink = strPathLink_All;
    var strUrlLocation = window.location.href;
    if (strUrlLocation.toLowerCase().indexOf("/yahoo/") != -1) {
        strUrlLink = strPathLink_All + "yahoo/";
    }
    if (obj.dsSubComment != "0") {
        for (var i = 0; i < obj.dsSubComment.length; i++) {
            strHtml += '<div class="dListSubCM">' +
               '<div class="div_imgList">' +
                '<a class="aImgMember aMemberListDis" href="' + strUrlLink + 'profile/photos.aspx?mid=' + obj.dsSubComment[i].idtk + '"><img width="50" height="50" src="' + obj.dsSubComment[i].avatar + '"></img></a>' +
                '<i class="divShadowListCW"></i>' +
               '</div>' +
               '<div class="TextComCP">' +
                    '<i class="tl_BPro"></i>' +
                    '<i class="ct_BPro"></i>' +
                    '<i class="tr_BPro"></i>' +
                    '<div class="cl_BPro">' +
                        '<div class="cr_BPro">' +
                            '<div class="div_innerCP">' +
                                '<p class="pTimeCP">' + obj.dsSubComment[i].tgtao + '</p>' +
                                '<a class="aMemberCP" title="' + obj.dsSubComment[i].nickname + '" href="' + strUrlLink + 'profile/photos.aspx?mid=' + obj.dsSubComment[i].idtk + '">' + obj.dsSubComment[i].nickname + '</a>' +
                                '<p class="pTextCP">' + obj.dsSubComment[i].noidung + '</p>' +
                            '</div>' +
                        '</div>' +
                    '</div>' +
                    '<i class="bl_BPro"></i>' +
                    '<i class="cb_BPro"></i>' +
                    '<i class="br_BPro"></i>' +
                    '<i class="div_ArrowCP"></i>' +
               '</div>' +
           '</div>';
        }
        $("subCount_" + obj.IDComm).innerHTML = obj.dsSubComment.length;
    }
    //if (!$('pMessLoiBinh')) {
        strHtml += '<div class="div_areaCom">' +
                '<i class="tl_area"></i>' +
                '<i class="ct_area"></i>' +
                '<i class="tr_area"></i>' +
                 '<div class="cl_area">' +
                     '<div class="cr_area">' +
                        '<div class="div_innerArea">' +
                        '<textarea id="txtSubComment_' + obj.IDComm + '" class="textareaCP"></textarea>' +
                        '</div>' +
                     '</div>' +
                '</div>' +
                '<i class="bl_area"></i>' +
                '<i class="cb_area"></i>' +
                '<i class="br_area"></i>' +
            '</div>' +
           '<div class="div_btnSendCP">' +
                 '<a href="javascript:void(0)" onclick="insertSubComment(' + obj.IDComm + ');" id="btnSub_' + obj.IDComm + '"  class="btnSendMailTB ">' + langMess()[0][12] + '</a>' +
            '</div>' +
            '<p class="styleText10 color20 pMessCP"><em></em></p>';
    //}
    $("divSubComment_" + obj.IDComm).style.display = "block";
    $("divSubComment_" + obj.IDComm).innerHTML = strHtml;
    $("txtSubComment_" + obj.IDComm).focus();
}
function insertSubComment(idComment) {
    if ($("txtSubComment_" + idComment).value.length > 0) {
        if (objLogin != null) {
            var strContent = $("txtSubComment_" + idComment).value;
            $("txtSubComment_" + idComment).value = "";
            strIDCommentSP = idComment;
            var strUrlLocation = window.location.href;
            var strUrlLink = strPathLink_All;
            if (strUrlLocation.toLowerCase().indexOf("/yahoo/") != -1) {
                strUrlLink = strPathLink_All + "yahoo/";
            }
            utils.call(strUrlLink + "Deal_Comment.aspx", { "flag": "insertsub", "id": idComment, "idtp": "8", "desc": strContent }, "POST", "showSubCommentSPResult", "showSubCommentSPResult");
        } else {
            showPopUpSIBuy();
        }
    }
}
/*function showCommentsByDeal(objComment) {
var strHtml = "";
for (var i = 0; i < objComment.dsComment.length; i++) {
strHtml += "<li>" +
"<div class='div_imgList'>" +
"<a class='aImgMember aMemberListDis' href='#'><img width='50' height='50' src='" + objComment.dsComment[i].avatar + "'></img></a>" +
"<div class='divShadowListCW'></div>" +
"</div>" +
"<div class='TextComCP'>" +
"<div class='tl_BPro'></div>" +
"<div class='ct_BPro'></div>" +
"<div class='tr_BPro'></div>" +
"<div class='cl_BPro'>" +
"<div class='cr_BPro'>" +
"<div class='div_innerCP'>" +
"<p class='pTimeCP'>" + objComment.dsComment[i].tgtao + "</p>" +
"<a class='aMemberCP' title='" + objComment.dsComment[i].nickname + "' href='#'>" + objComment.dsComment[i].nickname + "</a>" +
"<p class='pTextCP'>" + objComment.dsComment[i].noidung + "</p>" +
"</div>" +
"</div>" +
"</div>" +
"<div class='bl_BPro'></div>" +
"<div class='cb_BPro'></div>" +
"<div class='br_BPro'></div>" +
"<div class='div_ArrowCP'></div>" +
"</div>" +
"</li>";
}

strHtml += "<li class='liWriteCP'>" +
"<div class='TextComCP'>" +
"<div class='tl_BPro'></div>" +
"<div class='ct_BPro'></div>" +
"<div class='tr_BPro'></div>" +
"<div class='cl_BPro'>" +
"<div class='cr_BPro'>" +
"<div class='div_innerCP'>" +
"<p class='pWriteCom'>Viết lời bình</p>" +
"<div class='div_areaCom'>" +
"<div class='tl_area'></div>" +
"<div class='ct_area'></div>" +
"<div class='tr_area'></div>" +
"<div class='cl_area'>" +
"<div class='cr_area'>" +
"<div class='div_innerArea'>" +
"<textarea class='textareaCP'></textarea>" +
"</div>" +
"</div>" +
"</div>" +
"<div class='bl_area'></div>" +
"<div class='cb_area'></div>" +
"<div class='br_area'></div>" +
"</div>" +
"<div class='div_btnSendCP'>" +
"<a href='javascript:void(0);' id='btnSend' style='display:block' class='btnSendMailTB'>Gửi</a>" +
"</div>" +
"<p class='styleText8 color10 pMessCP'><em></em></p>" +
"</div>" +
"</div>" +
"</div>" +
"<div class='bl_BPro'></div>" +
"<div class='cb_BPro'></div>" +
"<div class='br_BPro'></div>" +
"</div>" +
"</li>";
$("ulComment").innerHTML = strHtml;
if ($("btnSend")) $("btnSend").onclick = sendCommentDeal;
}*/